package com.mmm.order.mq;

import com.mmm.order.service.ExpressService;
import com.mmm.order.variable.ExpressMQVaribale;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import static com.mmm.order.variable.ExpressMQVaribale.EXPRESS_DELETE_QUEUE;
import static com.mmm.order.variable.ExpressMQVaribale.EXPRESS_INSERT_QUEUE;

/**
 * @email 1067559930@qq.com
 * @author: One
 * @date: 2022/03/09
 * @time: 16:39
 */
@Component
public class MqListening {

    @Autowired
    private ExpressService expressService;

    @RabbitListener(queues = ExpressMQVaribale.EXPRESS_INSERT_QUEUE)
    public void insertQueueOrUpdate(Long id){
//        System.out.println("正在插入"+id);
        expressService.insertQueueOrUpdate(id);
    }

    @RabbitListener(queues = ExpressMQVaribale.EXPRESS_DELETE_QUEUE)
    public void deleteQueue(Long id){
//        System.out.println("正在删除"+id);
            expressService.deleteQueue(id);
    }
}

